<template>
  <el-card class="cardClass">
    <div slot="header" class="cardClass_header">
      <h3>分摊比例参数设置</h3>
    </div>
    <!-- 查询开始 -->
    <el-collapse-transition>
      <el-form
        :model="ruleForm"
        :inline="true"
        :rules="rules"
        ref="ruleForm"
        label-width="80px"
        v-if="hidden"
      >
        <el-form-item label="字段：" prop="key">
          <el-select
            v-model="ruleForm.key"
            placeholder="请选择查询字段"
            size="small"
          >
            <el-option
              v-for="item in keyOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="值：" prop="value">
          <el-input
            v-model="ruleForm.value"
            placeholder="请输入值"
            size="small"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            @click="submitForm('ruleForm')"
            size="small"
            icon="el-icon-search"
            >查询</el-button
          >
          <el-button
            @click="resetForm('ruleForm')"
            size="small"
            icon="el-icon-refresh"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
    </el-collapse-transition>
    <!-- 查询结束 -->

    <!-- 表格开始 -->
    <el-table
      :data="tableData"
      stripe
      v-loading="loading"
      size="small"
      border
      style="width: 100%"
    >
      <el-table-column
        prop="id"
        type="index"
        label="序号"
        width="50px"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="duniu0"
        label="犊牛0-3"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="duniu4"
        label="犊牛4-6"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="yucheng"
        label="育成"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="qingnianniu"
        label="青年牛"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="chengnianniu"
        label="成年牛"
        align="center"
      ></el-table-column>
      <el-table-column label="操作" align="center" width="220">
        <template slot-scope="scope">
          <el-button
            type="warning"
            size="mini"
            icon="el-icon-edit"
            @click="open('修改分摊比例参数', scope.row)"
            >修改</el-button
          >
          <el-button
            type="danger"
            size="mini"
            icon="el-icon-delete"
            @click="del(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-row :gutter="15" style="margin-top: 15px">
      <el-col :span="12">
        <el-card class="box-card-bottom">
          <div>
            <NewsalestrendsScaleParameter></NewsalestrendsScaleParameter>
          </div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card class="box-card-bottom">
          <div>
            <totalsalesScaleParameter></totalsalesScaleParameter>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <!-- 可视化结束 -->

    <!-- 分页开始 -->
<addEmployee ref="addEmployeeref"></addEmployee>
    <!-- 分页结束 -->
  </el-card>
</template>

<script>
import { queryemploye } from "@/apis/employee/employeeManagement.js";
import NewsalestrendsScaleParameter from "@/components/dataSreening/salesData/NewsalestrendsScaleParameter";
import totalsalesScaleParameter from "@/components/dataSreening/salesData/totalsalesScaleParameter";
import addEmployee from '@/components/employee/addEmployee.vue'
export default {
  components: {
    NewsalestrendsScaleParameter,
    totalsalesScaleParameter,
    addEmployee
  },
  data() {
    return {
      total: null, // 分页
      loading: false, // 加载
      hidden: false, // 控制搜索表单显示状态
      // 表格开始
      tableData: [],
      // 表格结束
      ruleForm: {
        key: "yucheng",
        value: "",
        pageNum: 1,
        pageSize: 5,
      },
      rules: {
        key: [{ required: true, message: "请选择查询字段", trigger: "blur" }],
      },
    };
  },
  created() {
    this.search();
  },
  methods: {
    // 新增/修改弹窗
    open(title, row) {
      this.$refs.addEmployeeref.show(title, row);
    },
    // 搜索方法
    search() {
      const _this = this;
      _this.loading = true;
      queryemploye(_this.ruleForm).then((res) => {
        _this.tableData = res.data;
        _this.total = res.total;
        _this.loading = false;
      });
    },

    // 重置
    resetForm(formName) {
      let _this = this;
      this.$refs[formName].resetFields();
      this.search(_this.ruleForm);
      this.ruleForm.pageNum = 1; // 查询重置页数
    },
  },
};
</script>

<style></style>